<% layout('/layouts/default.html', {title: '', libs: ['dataGrid']}){ %>
<!-- <link rel="stylesheet" href="${ctxStatic}/modules/sys/sysDesktop.css?${_version}"> -->
<style>
    *{
        margin:0px;
        padding:0px
    }
    p{
        margin:0px
    }
    .kanHeader p {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 700;
        color: #231815;
    }
    .workKey {
        border-radius: 4px;
        margin: 0 0 15px 0;
        text-align: center;
        background: #fff;
        -webkit-transition: -webkit-transform .3s;
        transition: -webkit-transform .3s;
        transition: transform .3s;
        transition: transform .3s,-webkit-transform .3s;
        padding: 0 24px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        padding-bottom: 15px;
        position: relative;
    }
    .shipTop {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        height: 54px;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        justify-content: space-between;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        width: 100%;
    }
    .shipTop h1 {
        font-size: 16px;
        font-weight: 500;
        margin:0px
    }
    .huls span {
        padding-left: 10px;
        font-size: 14px;
        cursor: pointer;
    }
    .huizong p{
        border-radius: 4px;
        text-align: center;
        height: 110px;
        -webkit-box-flex: 1;
        -ms-flex: 1;
        flex: 1;
        margin-right: 35px;
        cursor: pointer;
    }
    .huizong p span{
        display: block;
        color: #fff;
        font-size: 18px;
        padding-top: 20px;
    }
    .huizong p:last-child {
        margin-right: 0;
    }
    .sheachBao span {
        display: inline-block;
        margin-right: 10px;
        border-radius: 4px;
        font-size: 12px;
        color: #fff;
        padding: 0 5px;
        cursor: pointer;
        line-height: 24px;
    }
    .rightData .dataList span {
        padding-left: 10px;
        font-size: 14px;
        cursor: pointer;
    }
    .shipdivt li{
        display: inline-block;
        height: 32px;
        padding: 0 10px;
        line-height: 30px;
        font-size: 12px;
        color: #409eff;
        border: 1px solid #d9ecff;
        border-radius: 4px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        width: 58px;
        cursor: pointer;
        text-align: center;
        margin-right:10px;
        margin-bottom: 8px;
    }
    .ff{
        display: flex;
        align-items: center;
        justify-content: end;
    }
    .f{
        float: left;

    }
    .fff{
        width: 80%;
        display: flex;
        align-items: center;
        justify-content: end;
    }
    .f{
        width: 30%;
        min-width: 120px;
    }
</style>


    <div class="form-group ff">
        <div class="col-md-10 fff">
            <label class="control-label ">${text('标题')}：</label>
            <div class=" f">
                <#form:select path="title" items="${titles}" blankOption="true" data-placeholder="请选择" itemLabel="code" itemValue="name" class="form-control width-120" data-allow-clear="true" />
            </div>
        </div>
        <div style="min-width: 120px">
            <button type="submit" class="btn btn-primary btn-sm" onclick="initPic()">${text('查询')}</button>
            <button id="btnImport" class="btn btn-default btn-sm">${text('导入')}</button></div>
        </div>
    <div class="form-group">

    </div>

    <div class="workKey" style="margin-bottom: 0px;display: block" id="roll1_top2">
        <div class="shipTop">
            <h1>主要经济指标全省考核排名</h1>
            <p style="cursor: pointer; color: #4b87ff" onclick="more()" >更多</p>
        </div>
        <div class="box-echarts">
            <div style="height: 350px; width: 100%" id="myChart"></div>
        </div>
<!--        <div class="shipTop">-->
<!--            <h1>主要经济指标全省排名</h1>-->
<!--            <p style="cursor: pointer; color: #4b87ff" onclick="more2()" >更多</p>-->
<!--        </div>-->
<!--        <div class="box-echarts">-->
<!--            <div style="height: 350px; width: 100%" id="myChart2"></div>-->
<!--        </div>-->
    </div>

    <div class="row">

        <section class="col-md-5 ui-sortable ui-sortable">

        </section>
    </div>
</div>

<% } %>
<script src="${ctxStatic}/jquery/jquery-ui-sortable-1.12.1.min.js"></script>
<script src="${ctxStatic}/echarts/4.2/echarts.min.js"></script>
<script>
    var  myChart1;
    //打开经济指标排名更多
    function more() {
            js.addTabPage(null, "经济指标详情","${ctx}/dceconomicindicator/dcEconomicIndicator/list?title="+$("#title").val() , true);
    }
    function more2() {
        js.addTabPage(null, "经济指标详情","${ctx}/home/provinceMajor/list" , true);
    }
    $(function (){
        initPic()
      //  initPic2()
    });

    $('#btnImport').click(function(){
        js.layer.open({
            type: 1,
            area: ['400px'],
            title: '${text("导入主要经济指标数据")}',
            resize: false,
            scrollbar: true,
            content: js.template('importTpl'),
            success: function(layero, index){
                layero.find('input[type="checkbox"]').iCheck();
            },
            btn: ['<i class="fa fa-check"></i> ${text("导入")}',
                '<i class="fa fa-remove"></i> ${text("关闭")}'],
            btn1: function(index, layero){
                var form = {
                    inputForm: layero.find('#inputForm'),
                    file: layero.find('#file').val()
                };
                if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
                    js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
                    return false;
                }
                js.ajaxSubmitForm(form.inputForm, function(data){
                    js.showMessage(data.message);
                    if(data.result == Global.TRUE){
                        js.layer.closeAll();
                        window.location.reload()
                    }
                    page();
                }, "json");
                return true;
            }
        });
    });

    function initPic() {
        $.ajax({
            url: "${ctx}/dceconomicindicator/dcEconomicIndicator/getRank?title="+$("#title").val(),
            type: "post",
            cache: false,
            data: {},
            dataType: "json",
            success: function(res){
                myChart1 = echarts.init(document.getElementById('myChart'));
                myChart1.setOption({
                    tooltip : {
                        trigger: 'axis',
                        //柱形图tooltip内容优化代码
                        formatter: function (datas) {
                            var resName = datas[0].name + "<br/>";
                            for (var i = 0, length = datas.length; i < length; i++) {
                                //res.xAxisData是接口返回数据
                                // var index = res.xAxisData.findIndex(function (item) {
                                //     return item === datas[i].name
                                // }
                                // );
                                var index = 0;
                                for(var j = 0, length2 = res.xAxisData.length; j < length2; j++){
                                    if(res.xAxisData[j] === datas[i].name){
                                        index = j;
                                    }
                                }
                                var listp = res.tooltipData[index];
                            }
                            resName = resName + "省内排名：" + listp;
                            return resName;
                        },
                    },
                    color: ["#5087EC"],
                    toolbox: {
                        show: false,
                    },
                    // dataZoom: {
                    //     show: true,
                    //     realtime: true,
                    //     start: 0,
                    //     end: 60
                    // },
                    // dataZoom: [
                    //     {
                    //         id: "dataZoomX",
                    //         type: "slider",
                    //         // show:false,
                    //         height: 20,
                    //         start: 0, //数据窗口范围的起始百分比0-100
                    //         end: num, //数据窗口范围的结束百分比0-100
                    //         xAxisIndex: [0],
                    //         filterMode: "filter",
                    //         realtime: true,
                    //         bottom: 0,
                    //         textStyle: {
                    //             color: "#e7e7eb",
                    //         },
                    //
                    //     },
                    //     //2.在内部可以横向拖动
                    //     {
                    //         type: "inside", // 内置于坐标系中
                    //         start: 0,
                    //         end: 30,
                    //         xAxisIndex: [0],
                    //     },
                    // ],
                    grid : {
                        top: "3%",
                        left: "0%",
                        right: "0%",
                        bottom: "15px",
                        containLabel: true,
                    },
                    xAxis : [
                        {
                            type : 'category',
                            axisLabel: {
                                //坐标轴刻度标签的相关设置。
                                borderWidth:10,
                                interval:'auto',
                                rotate: "50",
                                showMinLabel:true,
                                showMaxLabel:true,
                            },

                            data : res.xAxisData
                        }

                    ],
                    yAxis : [
                        {
                            type: "value",
                            show: true,
                            axisLabel: {
                                show: true,
                                textStyle: {
                                    color: "#fff",
                                },
                            },
                        }
                    ],

                    series : [
                        {
                            type: "bar",
                            data:res.seriesData,

                        },

                    ]
                });
                window.addEventListener('resize',function () {//执行
                    myChart1.resize();
                })
            }
        });
    }

    function initPic2() {
        $.ajax({
            url: "${ctx}/home/provinceMajor/getRank",
            type: "post",
            cache: false,
            data: {},
            dataType: "json",
            success: function(res){
                myChart1 = echarts.init(document.getElementById('myChart2'));
                myChart1.setOption({
                    tooltip : {
                        trigger: 'axis',
                        //柱形图tooltip内容优化代码
                        formatter: function (datas) {
                            var resName = datas[0].name + "<br/>";
                            for (var i = 0, length = datas.length; i < length; i++) {
                                //res.xAxisData是接口返回数据
                                // var index = res.xAxisData.findIndex(function (item) {
                                //     return item === datas[i].name
                                // }
                                // );
                                var index = 0;
                                for(var j = 0, length2 = res.xAxisData.length; j < length2; j++){
                                    if(res.xAxisData[j] === datas[i].name){
                                        index = j;
                                    }
                                }
                                var listp = res.tooltipData[index];
                            }
                            resName = resName + "扣分：" + listp;
                            return resName;
                        },
                    },
                    color: ["#5087EC"],
                    toolbox: {
                        show: false,
                    },
                    // dataZoom: {
                    //     show: true,
                    //     realtime: true,
                    //     start: 0,
                    //     end: 60
                    // },
                    // dataZoom: [
                    //     {
                    //         id: "dataZoomX",
                    //         type: "slider",
                    //         // show:false,
                    //         height: 20,
                    //         start: 0, //数据窗口范围的起始百分比0-100
                    //         end: num, //数据窗口范围的结束百分比0-100
                    //         xAxisIndex: [0],
                    //         filterMode: "filter",
                    //         realtime: true,
                    //         bottom: 0,
                    //         textStyle: {
                    //             color: "#e7e7eb",
                    //         },
                    //
                    //     },
                    //     //2.在内部可以横向拖动
                    //     {
                    //         type: "inside", // 内置于坐标系中
                    //         start: 0,
                    //         end: 30,
                    //         xAxisIndex: [0],
                    //     },
                    // ],
                    grid : {
                        top: "3%",
                        left: "0%",
                        right: "0%",
                        bottom: "15px",
                        containLabel: true,
                    },
                    xAxis : [
                        {
                            type : 'category',
                            axisLabel: {
                                //坐标轴刻度标签的相关设置。
                                interval:'auto',
                                rotate: "50",
                                showMinLabel:true,
                                showMaxLabel:true,
                            },

                            data : res.xAxisData
                        }

                    ],
                    yAxis : [
                        {
                            type: "value",
                            show: true,
                            axisLabel: {
                                show: true,
                                textStyle: {
                                    color: "#fff",
                                },
                            },
                        }
                    ],

                    series : [
                        {
                            type: "bar",
                            data:res.seriesData,

                        },

                    ]
                });
                window.addEventListener('resize',function () {//执行
                    myChart1.resize();
                })
            }
        });
    }

</script>

<script id="importTpl" type="text/template">
    <form id="inputForm" action="${ctx}/dceconomicindicator/dcEconomicIndicator/importInfo2" method="post" enctype="multipart/form-data"
          class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
        <div class="row">
            <div class="col-xs-12 col-xs-offset-1">
                <input type="file" id="file" name="file" class="form-file"/>
                <div class="mt10 pt5">
                    <a href="${ctx}/dceconomicindicator/dcEconomicIndicator/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
                </div>
                <font color="red" class="pull-left mt10">
                    ${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
                </font>
            </div>
        </div>
    </form>
</script>